<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="帐套" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<script src="/js/jquery.js"></script>
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doSave(){
		document.getElementById("buttonDiv").style.display="none";
		document.getElementById("waitDiv").style.display="";
		frm.submit();
	}
	function doCancel(){
		parent.ClosePop();
	}
	function showMe(){
		showFormErrorMsg();
	}
	function doCheck(){
		var tsName=$("#title").val();
		var expId="${command.id}";
		if(tsName!=""){
			$.post("/system/CheckTs.ihtm",{ts_name:tsName,exp_id:expId},function(data,status){
				parseCheckData(data,status);
			});
		}
	}
	function parseCheckData(data,status){
		if(status=="success"){
			var obj=$.parseJSON(data);
			if(obj.status=="ERROR"){
				ShowAlert('提示框',obj.errMsg,200,100);
			}else if(obj.status=="EXIST"){
				ShowConfirm('确认框','名称已经存在，恢复帐套吗？',340,80,"doCheckCallBack()");
			}else{
				ShowAlert('提示框','没有存在此名称的帐套',200,100);
			}
		}else{
			ShowAlert('提示框','系统错误：'+status,200,100);
		}
	}
	function doCheckCallBack(){
		if(popRetVal!=null){
			var tsName=$("#title").val();
			$.post("/system/RecoverTs.ihtm",{ts_name:tsName},function(data,status){
				parseRecoverData(data,status);
			});
		}
	}
	function parseRecoverData(data,status){
		if(status=="success"){
			var obj=$.parseJSON(data);
			if(obj.status=="ERROR"){
				ShowAlert('提示框',obj.errMsg,200,100);
			}else{
				parent.popRetVal="OK";
				parent.ClosePop();
			}
		}else{
			ShowAlert('提示框','系统错误：'+status,200,100);
		}
	}
</script>
</head>
<body oncontextmenu="return false" scroll="no" onLoad="showMe();" class="sheet modal-dialog" style=" padding-top:5px;">
<div class="sheet-main" id="bodyDiv" style="width:320px;">
	<form name="frm" method="post">
	  <div class="sheet-list" style="width:100%">
	    <div class="modal-main search-business">
	    	<div style="width:100%;">
				<c:if test="${id==null || id==''}"><c:set var="pageTopTitle" value="新增帐套" /></c:if>
				<c:if test="${id!=null && id!=''}"><c:set var="pageTopTitle" value="编辑帐套" /></c:if>
				<%@ include file="../inc/PageTop.jsp"%> 
				<table border="0" cellspacing="1" cellpadding="1" align="center" class="table-a">
					<tr>
				      	<th><span class="MustInput">*</span>账套名称：</th>
				      	<spring:bind path="command.title">
				      	<td>
				      		<input type="text" class="TextBox" maxlength="15" id="${status.expression}" name="${status.expression}" value="${status.value}">
				      		<img class="make-a" src="/images/make-c.gif" style="cursor:pointer;" onClick="doCheck();" title="查出哪些是重名的，已删除的重名帐套可以在这里恢复">					
					        <script language="javascript">
					          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',1,'title');
					        </script>
			     		</td>
			     		</spring:bind>
					</tr>
				</table>
			</div>	
	  	</div>
	  </div>
		<div class="modal-buttom" id="buttonDiv">
			<input type="button" class="buttom-a" value=" 保 存 " onClick="doSave();">
			<input type="button" class="buttom-a" value=" 取 消 " onClick="doCancel();">
			<input type="hidden" name="flag" id="flag" value="1">		
		</div>
		<div class="modal-buttom" id="waitDiv" style="display:none">
			<span style="color:#ffffff">请稍候...</span>
		</div>
	</form>
</div>	
</body>
</html>